﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using RollBackLib.src.core;

namespace RollBack.src.ui
{
    public partial class JobFinishedDialog : Form
    {
        public JobFinishedDialog()
        {
            InitializeComponent();
            this.Name = AppUI.m_DialogTitle;
            this.Text = AppUI.m_DialogTitle;
        }

        internal void setStatus(string oprMsg, BackupInfo bInfo)
        {
            BackupStatistics stats = bInfo.m_Statistics;
            Icon icon = System.Drawing.SystemIcons.Information;
            string status = "Finished ";
            switch (bInfo.m_Job.m_lastRunSuccess)
            {
                case BackupInfo.LastRunResult.ABORTED:
                    status = "Aborted ";
                    icon = System.Drawing.SystemIcons.Hand;
                    break;
                case BackupInfo.LastRunResult.FAILED:
                    status = "Failed ";
                    icon = System.Drawing.SystemIcons.Error;
                    break;
                case BackupInfo.LastRunResult.FINISHED:
                    status = "Finished ";
                    icon = System.Drawing.SystemIcons.Information;
                    break;
            }
            textBox1.Text =
                status +
                " <" + bInfo.m_Job.m_Id.m_Name + ">\r\n" +
                "Guid: " + bInfo.m_Job.m_Id.m_Guid + "\r\n\r\n" +
                oprMsg;
            m_finishIcon.Image = icon.ToBitmap();
        }
    }
}
